#ifndef __UDSF_DATA_FORMAT_CONVERT_
#define __UDSF_DATA_FORMAT_CONVERT_

#include "app.h"

/*
*   notice:
*   UDSF 同UDF编程：不可调用cstd-lib,只可调用"sdk_ifs_udk_cfg.h"、"sys_api.h"中列出的API函数。
*   UDSF文件内函数均需使用static修饰符，且UDF中以#include "udsf_xxx.c"形式引用
*/
#include "udsf_sys_api.c"

static uint32_t udsf_dfc_fp_2_psf(uint32_t real,uint32_t image)
{
	uint32_t tmp = *(uint32_t*)BBE_ABUF0_BASE;
	
	*(uint32_t*)(BBE_ABUF0_CMPLX_BASE+0) = real;
	*(uint32_t*)(BBE_ABUF0_CMPLX_BASE+4) = image;
	
	uint32_t psf = *(uint32_t*)BBE_ABUF0_BASE;
	
	*(uint32_t*)BBE_ABUF0_BASE = tmp;
	
	return psf;
}

static uint32_t udsf_dfc_psf_2_abs(uint32_t psf)
{
	uint32_t tmp = *(uint32_t*)BBE_ABUF0_BASE;
	
	*(uint32_t*)BBE_ABUF0_BASE = psf;
	
	uint32_t abs = *(uint32_t*)(BBE_ABUF0_BASE+BBE_ABS_OFFSET);
	
	*(uint32_t*)BBE_ABUF0_BASE = tmp;
	
	return abs;
}

static void udsf_dfc_psf_2_fp(uint32_t *p_fixed_real,uint32_t *p_fixed_image,uint32_t psf)
{
	uint32_t tmp = *(uint32_t*)BBE_ABUF0_BASE;
	
	*(uint32_t*)BBE_ABUF0_BASE = psf;
	
	*p_fixed_real  = *(uint32_t*)(BBE_ABUF0_CMPLX_BASE+0);
	*p_fixed_image = *(uint32_t*)(BBE_ABUF0_CMPLX_BASE+4);
	
	*(uint32_t*)BBE_ABUF0_BASE = tmp;
}




#endif
